//
//  NetWorkingAddress.m
//  MobileShoppingMall
//
//  Created by 冯传昌 on 2021/4/27.
//  Copyright © 2021 冯传昌. All rights reserved.
//

#import "NetWorkingAddress.h"

@implementation NetWorkingAddress

//获取地址列表
+(void)getAddressListWithSuccessBlock:(void(^)(id responseObj))successBlock{
    [NetWorkTool requestTokenGetWithUrl:DeliverList withSuccessBlock:^(id  _Nonnull responseObj) {
        successBlock(responseObj);
    } withFailedBlock:^(NSString * _Nonnull errorStr) {
        [[XNProgressHUD shared] showErrorWithTitle:@"网络错误"];
    }];
}

//获取地址列表
+(void)updateAddress:(AddressModel *)model WithSuccessBlock:(void(^)(id responseObj))successBlock{
    NSString *urlStr = [NSString stringWithFormat:@"%@/%ld",Deliver,model.ID];
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    params[@"linker"] = model.linker;
    params[@"linkphone"] = model.linkphone;
    params[@"province"] = model.province;
    params[@"city"] = model.city;
    params[@"region"] = model.region;
    params[@"address"] = model.address;
    params[@"label"] = model.label;
    params[@"isdefault"] = @(model.isdefault);
    
    [NetWorkTool requestTokenPostWithUrl:urlStr WithParams:params withSuccessBlock:^(id  _Nonnull responseObj) {
        successBlock(responseObj);
    } withFailedBlock:^(NSString * _Nonnull errorStr) {
        [[XNProgressHUD shared] showErrorWithTitle:@"网络错误"];
    }];
}
//删除地址
+(void)deleteAddress:(AddressModel *)model WithSuccessBlock:(void(^)(id responseObj))successBlock{
    
    NSString *urlStr = [NSString stringWithFormat:@"%@/%ld",DeliverDel,model.ID];
    [NetWorkTool requestTokenPostWithUrl:urlStr WithParams:@{} withSuccessBlock:^(id  _Nonnull responseObj) {
        successBlock(responseObj);
    } withFailedBlock:^(NSString * _Nonnull errorStr) {
        [[XNProgressHUD shared] showErrorWithTitle:@"网络错误"];
    }];
}


@end
